package leecode

import "sort"

func checkDynasty(places []int) bool {
	sort.Ints(places)
	index := 0
	for i := 0; i+1 < len(places); i++ {
		if places[i] == 0 {
			index++
		} else if places[i] == places[i+1] {
			return false
		}

	}
	if places[len(places)-1]-places[index] < 5 {
		return true
	}
	return false
}
